<?php

function buildData($temp, $count) {
    $data = array();
    $no = 0;
    if ($temp != false && count($temp) > 0) {
        foreach ($temp as $row) {
            $url = $row['url'];
            $start = "http://update.lz06.com/";
            $array = explode($start, $url);
            $str = "../update/video/" . $array[1];

            if (file_exists($str)) {
                $url = $start . "video/" . $array[1];
                $row['url'] = $url;

                $fp = fopen($url, "r");
                if ($fp) {
                    $a_array = get_headers($url, true);
                    $size = round($a_array['Content-Length'] / (1024 * 1000), 3);
                    $row['size'] = strval(intval($size));
                }
                array_push($data, $row);
                $no++;
                if (isset($count) && $no == $count) {
                    break;
                }
            }
        }
    }
    return $data;
}
?>
